home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT12 / CODEC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-24  |  3.6 KB  |  74 lines

  1.  
  2. /**********************************************************************
  3. *
  4. *  Determining the video adapter type and output the code of a key pressed
  5. *
  6. *  Author:  A.I.Sopin   Voronezh, 1992
  7. *
  8. *  External functions used (the library C60S.LIB):
  9. *
  10. *  DIAM04,  CCOLOR, CVIDEO, CCURS
  11. *
  12. **********************************************************************/
  13. #include <stdio.h>
  14. #include <dos.h>
  15. extern void CCOLOR (int  M, int  N, int  C);
  16. extern void DIAM04 (int OP, int M, int N, char *Tp, int L, int U, int V,
  17.                     int *Qp, int *Sp, unsigned char *Wp, char *Ip);
  18. extern void CVIDEO (char *VTYPE);
  19. extern void CCURS (int U, int V);
  20. union  REGS  regs;
  21.  
  22. void main ()
  23. {
  24. static int   U = 5, V = 1, Q = 1, S;
  25. static unsigned  char W[4], Fin[ ] = {" ***  End of job (press"
  26.                                       "any key to exit)  *** " };
  27. static char I [5] = { 48, 16, 0, 0x74, 0 }, Nregim, VT [4], Inp;
  28. /*-------------------------------------------------------------------------*/
  29.     regs.h.ah = 0x0f;                /*  function 0Fh - get video mode     */
  30.     regs.h.bh = 0;                   /*  BH - video page number            */
  31.     int86 (0x10, ®s, ®s);      /* BIOS/DOS service call (interrupt)  */
  32.     Nregim = regs.h.al;              /*  save video mode                   */
  33.     CCOLOR (1, 25, 0x1e);            /*  clear screen and set color        */
  34.     CVIDEO (VT);                     /*  determine video adapter type      */
  35.     CCURS (2, 1);                    /*  position cursor for printf ( )    */
  36.     printf ("Adapter type =%s", VT); /*  output video adapter type (line 2)*/
  37.     printf (" (Press any key)");     /*  output prompt                     */
  38.     gets (&Inp);                     /*  wait for key pressing             */
  39. /*-------------------------------------------------------------------------*/
  40. /*  This cycle outputs 24 lines onto the screen                            */
  41.  
  42.     *(W+1) = 0;                      /*  clear key code                    */
  43.     while (Q <= 24)                  /*  until 24 lines aren't output...   */
  44.     {
  45.       DIAM04 (1, 3, -3, "DIAM04 testing (\"ESC\" - exit)    ",
  46.               80, U, V, &Q, &S, W, 0);
  47.       DIAM04 (10, 3, -3, "  ", 80, U, V, &Q, &S, W, 0);
  48.       printf ("Code: ASCII=%02X  SCAN=%02X  0:417=%02X  0:418=%02X",
  49.                *W, *(W+1), *(W+2), *(W+3));
  50.       if (*(W+1) == 0x01)             /* ESC - finish work                 */
  51.         {
  52.            putch (0x07);              /*  generate sound signal            */
  53.            DIAM04 (1, 3, -3, "  ", 80, U, V, &Q, &S, W, 0);
  54.            break;                     /*  cycle "while" ends here          */
  55.         }
  56.       U++;
  57.       V++;
  58.     } /* End  while (Q <= 24) */
  59. /*-------------------------------------------------------------------------*/
  60. /*  Restore video mode and exit                                            */
  61.     CCOLOR (1, 25, 0x1e);             /*  Clear screen (lines 1-25)        */
  62.     I[0] =48;                         /*  creating array of screen         */
  63.     I[1] =16;                         /*  control codes                    */
  64.     I[2] =0;
  65.     I[3] =0x74;                       /*  red characters on grey           */
  66.     I[4] =0;                          /*  (see description of DIAM04)      */
  67.     DIAM04 (2,12,-12, Fin, 80, 0, 0, &Q, &S, W, I);
  68.     regs.h.ah = 0x00;                 /*  function 0 - set video mode      */
  69.     regs.h.al = Nregim;               /*  saved video mode into AL         */
  70.     int86 (0x10, ®s, ®s);       /* BIOS/DOS service call (interrupt)  */
  71.     return;
  72. }
  73.  
  74.